#include <iostream>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cerrno>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#define PATH_NAME "./myPipe"
#define MY_MODE 0600

bool createFifo(const std::string& path, mode_t mode)
{
    int ret = mkfifo(path.c_str(), mode);
    if(ret == 0) return true;
    else
    {
        std::cout << "errno:" << errno << " -> " << strerror(errno) << std::endl;
        return false;
    }
}

void deleteFifo(const std::string& path)
{
    int ret = unlink(path.c_str());
    // if(ret == 0) return true;
    // else
    // {
    //     std::cout << "errno:" << errno << " -> " << strerror(errno) << std::endl;
    //     return false;
    // }
    assert(ret == 0);
    (void)ret;
    std::cout << "delete namedFifo success!" << std::endl;
}